<?php $this->load->view('home/layout/header') ?>
<header class="my-head flex">
    <div class="my-return">
        <a href="<?php echo site_url('home/ucenter/index'); ?>">
            <i class="iconfont icon-zuojiantou"></i>
        </a>
    </div>
    <div class="my-name">
        我的账户
    </div>
</header>
<section class="my-text widthMax">
    <div class="my-photo-personal">
        <label class="personal-photo">
            <img class="photo-img" src="<?php echo $userInfo->personal_photo ? $this->config->show_image_url($userInfo->personal_photo) : '/skins/common/images/photo0.jpg';?>">
            <input type="file" name="personal_photo" style="display: none;">
            <input type="hidden" name="personal_photo" value="<?php echo $userInfo->personal_photo ?>">
        </label>
        <div class="user-personal"><?php echo $userInfo->alias_name ? $userInfo->alias_name : ($userInfo->user_name ? $userInfo->user_name : $userInfo->mobile_phone); ?></div>
    </div>
    <ul class="my-list">
        <li>
            <a href="javascript:;" class="flex">
                <p class="flex-1">会员类型</p>
                <div class="my-photo flex">
                    <div class="photo-text flex-1">
                        <?php echo  ($this->userTypeName == '消费者') ? '会员' : $this->userTypeName; ?>
                    </div>
                </div>
            </a>
        </li>
    </ul>
    <ul class="my-list">
        <li>
            <a href="<?php echo site_url('home/ucenter/modifyUserName');?>" class="flex">
                <p class="flex-1">用户名称</p>
                <div class="my-photo flex">
                    <div class="photo-text flex-1">
                        <?php echo $userInfo->user_name; ?>
                    </div>
                    <?php if (empty($userInfo->user_name)) : ?>
                        <i class="iconfont icon-youjiantou"></i>
                    <?php endif; ?>
                </div>
            </a>
        </li>
        <li>
            <a href="<?php echo site_url('home/ucenter/modifyAlias'); ?>" class="flex">
                <p class="flex-1">昵　　称</p>
                <div class="my-photo flex">
                    <div class="photo-text flex-1">
                        <?php echo $userInfo->alias_name; ?>
                    </div>
                    <?php if (empty($userInfo->alias_name)) : ?>
                        <i class="iconfont icon-youjiantou"></i>
                    <?php endif; ?>
                </div>
            </a>
        </li>
        <?php if ($userInfo->mobile_phone) : ?>
            <li>
                <a href="<?php echo site_url('home/safetycenter/selectMobilePhone'); ?>" class="flex">
                    <p class="flex-1">手机号码</p>
                    <div class="my-photo flex">
                        <div class="photo-text flex-1">
                            <?php echo $userInfo->mobile_phone; ?>
                        </div>
                    </div>
                </a>
            </li>
        <?php endif; ?>
    </ul>
    <ul class="my-list">
        <li>
            <a href="<?php echo site_url('home/passenger/passengerList'); ?>" class="flex">
                <p class="flex-1">常用联系人</p>
                <div class="my-photo flex">
                    <div class="photo-text flex-1"></div>
                    <i class="iconfont icon-youjiantou"></i>
                </div>
            </a>
        </li>
        <li>
            <a href="<?php echo site_url('home/address/addressList'); ?>" class="flex">
                <p class="flex-1">收货地址</p>
                <div class="my-photo flex">
                    <div class="photo-text flex-1"></div>
                    <i class="iconfont icon-youjiantou"></i>
                </div>
            </a>
        </li>
    </ul>
    <ul class="my-list">
        <li>
            <a href="<?php echo site_url('home/safetycenter/selectModifyPass'); ?>" class="flex">
                <p class="flex-1">修改密码</p>
                <div class="my-photo flex">
                    <div class="photo-text flex-1"></div>
                    <i class="iconfont icon-youjiantou"></i>
                </div>
            </a>
        </li>
    </ul>
    <a href="<?php echo site_url('login/login/logout'); ?>" class="my-quit flex flex-pack-center">
        退出登录
    </a>
</section>
<?php $this->load->view('home/layout/footer') ?>
<script type="text/javascript">
    $('.my-photo-personal').on('change', 'input[type=file]', function (e) {
        var $this = $(this);
        upLoadImg(e.currentTarget.files[0], function (obj) {
            console.log(obj);
            $.ajax({
                type: 'post',
                dataType: 'json',
                async: false,
                url: hostUrl() + 'ucenter/modifyUserPost.html',
                data: {
                    personal_photo: obj.save_path
                },
                success: function (res) {
                    if (res.status) {
                        $this.siblings('[type=hidden]').val(obj.save_path);
                        $this.siblings('.photo-img').attr('src', obj.file_url);
                    } else {
                        alertMessage(res.msg);
                    }
                }
            });
        });
    });
</script>
